///////////////////////////////////////////////////////////////////////////////
// Volatile Bytes'
// Software Project Library
//
// Copyright (c) 2010-2012, Volatile Bytes
// Copyright (c) 2010-2012, Vincent Tremblay
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
//   this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright notice,
//   this list of conditions and the following disclaimer in the documentation
//   and/or other materials provided with the distribution.
//
// * Neither the name Volatile Bytes nor the names of its contributors may be
//   used to endorse or promote products derived from this software without
//   specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
///////////////////////////////////////////////////////////////////////////////

#ifndef SPL_EXTERN
#define SPL_EXTERN

#pragma comment(lib, "gdiplus.lib")
#pragma comment(lib, "msimg32.lib")
#pragma comment(lib, "comctl32.lib")
#pragma comment(lib, "shell32.lib")
#pragma comment(lib, "uxtheme.lib")

#include "spl.includes.h"

#pragma warning(push)

#define DLLEXPORT   __declspec(dllexport)
#define NOVTABLE    __declspec(novtable)

// library inline prefixes
#define SPLINL      __forceinline
#define SPLINLC     __forceinline const

#define ASSERT_MODE_BREAK   0
#define ASSERT_MODE_OUTPUT  1
#define ASSERT_MODE_MESSAGE 2

// use only common window messages for a smaller library
#define COMMON_WM_ONLY
// break on assert failure
#define ASSERT_MODE ASSERT_MODE_BREAK

#undef min
#undef max

template <bool, class, class>
struct static_if_else;

template <class trueT, class falseT>
struct static_if_else<true, trueT, falseT>
{
  typedef typename trueT type;
};

template <class trueT, class falseT>
struct static_if_else<false, trueT, falseT>
{
  typedef typename falseT type;
};

template <class Type1, class Type2>
typename static_if_else<(sizeof(Type1) > sizeof(Type2)),
typename Type1,
typename Type2>::type min(Type1 t1, Type2 t2)
{
  return (t1 < t2) ? t1 : t2;
}

template <class Type1, class Type2>
typename static_if_else<(sizeof(Type1) > sizeof(Type2)),
typename Type1,
typename Type2>::type max(Type1 t1, Type2 t2)
{
  return (t1 > t2) ? t1 : t2;
}

namespace Gdip = Gdiplus;

namespace SPLib
{
  // misc utilities
#include "spl.macros.h"

  // generic classes
  namespace Generic
  {
#include "spl.vector.h"
  }

  // drawing utilities
  namespace Geom
  {
#include "spl.geom.h"
#include "spl.drawing.h"
  }

  // ole utilities
  namespace Ole
  {
#include "spl.enumformatetc.h"
#include "spl.dataobject.h"
#include "spl.ole.h"
#include "spl.clipboard.h"
  }

  namespace Event
  {
#include "spl.msgstruct.h"
  }

  // window utilities
  namespace Windows
  {
    DLLEXPORT VOID initWindows();
    DLLEXPORT VOID uninitWindows();

#include "spl.wrapwnd.h"
#include "spl.wndbase.h"
#include "spl.framewnd.h"
#include "spl.framewnd.dropsource.h"
#include "spl.framewnd.droptarget.h"
#include "spl.window.h"
#include "spl.dialog.h"
#include "spl.hiddenwnd.h"
#include "spl.dwm.h"
  }

  // layout managers
  namespace Layout
  {
#include "spl.layout.h"
  }

  // custom controls
  namespace Controls
  {
#include "spl.control.h"
#include "spl.button.h"
#include "spl.label.h"
#include "spl.picturebox.h"
#include "spl.separator.h"
#include "spl.toolbar.h"
  }

  // setting managers
  namespace Settings
  {
#include "spl.parsing.h"
#include "spl.settings.h"
  }

  // IO functions
  namespace IO
  {
#include "spl.io.h"
  }
}

// inline operators
#include "spl.operators.h"

#pragma warning(pop)

#endif